import type { FastifyPluginCallback } from "fastify";
import fp from "fastify-plugin";

const shutdownPlugin: FastifyPluginCallback = (server, options, done) => {
	process.once("SIGINT", () => server.close());
	process.once("SIGTERM", () => server.close());

	done();
};

export default fp(shutdownPlugin, {
	name: "ClosePlugin",
});
